import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

public class java002 {
    public static void main(String[] args){
        ArrayList<Student> students=new ArrayList<Student>();
        addStudent(students,3);
        printStudent(students);
        System.out.println("幸运儿是"+randomStudent(students));
    }
    //----------------------------------------------------
    public static void addStudent(ArrayList<Student> s,int n){
        Scanner scanner=new Scanner(System.in);
        for(int i=0;i<n;i++){
            Student a=new Student();
            System.out.println("输入");
            a.setName(scanner.next());
            a.setAge(scanner.nextInt());
            a.setId(i);
            s.add(a);
        }
    }
    //-------------------------------------------------
    public static void printStudent(ArrayList<Student> s){
        for(int i=0;i< s.size();i++){

            s.get(i).getStudent();
        }
    }
    //--------------------------------------------
    public  static String randomStudent(ArrayList<Student> s){
        int index=new Random().nextInt(3);
        return s.get(index).getName();
    }
}
